package leetcode.code438;

import java.util.List;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

/**
 * @author Max
 * @date 2021年9月1日
 * @description 438.找到字符串中所有字母异位词 <br>
 *              https://leetcode-cn.com/problems/find-all-anagrams-in-a-string/
 */
public abstract class Solution438 implements IDebug {

	public abstract List<Integer> findAnagrams(String s, String p);

	@Override
	public void debug1() {
		String s = "cbaebabacd";
		String p = "abc";
		String expectStr = "[0,6]";
		this.debug(s, p, expectStr);
	}

	private void debug(String s, String p, String expectStr) {
		List<Integer> result = this.findAnagrams(s, p);
		List<Integer> expect = HelpDebug.str2intlist(expectStr);
		HelpDebug.compare(expect, result);

	}

	@Override
	public void debug2() {
		String s = "abab";
		String p = "ab";
		String expectStr = "[0,1,2]";
		this.debug(s, p, expectStr);
	}

	@Override
	public void debug3() {
//		不能一股脑的将慢针追到快针，因为可能慢针释放一个就是当前快针所需要的
//		而且后续有答案
		String s = "abacbabc";
		String p = "abc";
		String expectStr = "[1,2,3,5]";
		this.debug(s, p, expectStr);
	}

	@Override
	public void debug4() {
		String s = "aaaaaaaaaa";
		String p = "aaaaaaaaaaaaa";
		String expectStr = "[]";
		this.debug(s, p, expectStr);
	}

}
